//=============================================================================
// BoomStick Single Fire
//=============================================================================
class BoomStick1AltFire extends BoomStickAltFire;

simulated function bool AllowFire()
{
	local KFPlayerReplicationInfo KFPRI;
	
	KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);

	if( KFPRI.ClientVeteranSkillLevel > 9 && KFPRI.ClientVeteranSkill == class'SRVetSupportSpec' )
		Spread = 2250;
	else Spread = default.Spread;

	return (Weapon.AmmoAmount(0) >= AmmoPerFire);
}

event ModeDoFire()
{
	local float ExpenceMod;
	
	ExpenceMod = 1.0;
	ExpenceMod *= Max(1,ProjPerFire);
	ExpenceMod *= Max(1,AmmoPerFire);

	SRHumanPawn(Instigator).ConsumeStamina(ProjectileClass.default.Damage * ExpenceMod * 0.003 * 2.25);
	Super.ModeDoFire();
}

function DoFireEffect()
{
	local Vector StartProj, StartTrace, X,Y,Z;
    local Rotator R, Aim;
    local Vector HitLocation, HitNormal;
    local Actor Other;
    local int p;
    local int SpawnCount;
    local float theta;

//	SRHumanPawn(Instigator).ConsumeStamina(WeaponStaminaCost());

	Instigator.MakeNoise(1.0);
	SRHumanPawn(Instigator).BecomeVisible();

    Weapon.GetViewAxes(X,Y,Z);

    StartTrace = Instigator.Location + Instigator.EyePosition();// + X*Instigator.CollisionRadius;
    StartProj = StartTrace + X*ProjSpawnOffset.X;
    if ( !Weapon.WeaponCentered() && !KFWeap.bAimingRifle )
	    StartProj = StartProj + Weapon.Hand * Y*ProjSpawnOffset.Y + Z*ProjSpawnOffset.Z;

    // check if projectile would spawn through a wall and adjust start location accordingly
    Other = Weapon.Trace(HitLocation, HitNormal, StartProj, StartTrace, false);

// Collision attachment debugging
 /*   if( Other.IsA('ROCollisionAttachment'))
    {
    	log(self$"'s trace hit "$Other.Base$" Collision attachment");
    }*/

    if (Other != None)
    {
        StartProj = HitLocation;
    }

    Aim = AdjustAim(StartProj, AimError);

    SpawnCount = Max(1, ProjPerFire * int(Load));

    switch (SpreadStyle)
    {
    case SS_Random:
        X = Vector(Aim);
        for (p = 0; p < SpawnCount; p++)
        {
            R.Yaw = Spread * (FRand()-0.5);
            R.Pitch = Spread * (FRand()-0.5);
            R.Roll = Spread * (FRand()-0.5);
            SpawnProjectile(StartProj, Rotator(X >> R));
        }
        break;
    case SS_Line:
        for (p = 0; p < SpawnCount; p++)
        {
            theta = Spread*PI/32768*(p - float(SpawnCount-1)/2.0);
            X.X = Cos(theta);
            X.Y = Sin(theta);
            X.Z = 0.0;
            SpawnProjectile(StartProj, Rotator(X >> Aim));
        }
        break;
    default:
        SpawnProjectile(StartProj, Aim);
    }

	if (Instigator != none && Instigator.Physics != PHYS_Falling)
		Instigator.AddVelocity(KickMomentum >> Instigator.GetViewRotation());
}

defaultproperties
{
//	AmmoClass=Class'SecondaryFireReplacementAmmo'
	ProjectileClass=Class'BoomStick1Bullet'
}
